<template>
  <nav class="navbar">
    <router-link to="/conversation" class="logo">
      <img class="img-fluid" src="@/assets/logo.png" alt="Logo" />
    </router-link>
    <ul class="nav-links">
      <li>
        <router-link to="/" active-class="active-link">
          <span class="navname">
            <HomeOutlined />
            <span style="margin-left: 6px">首页</span>
          </span>
        </router-link>
      </li>
      <li>
        <router-link to="/conversation" active-class="active-link">
          <span class="navname">
            <UsergroupAddOutlined />
            <span style="margin-left: 6px">智能对话</span>
          </span>
        </router-link>
      </li>
      <li>
        <router-link to="/management" active-class="active-link"
          ><span class="navname">
            <DatabaseFilled />
            <span style="margin-left: 6px">数据管理</span>
          </span></router-link
        >
      </li>
      <li>
        <router-link :to="{ name: 'Knowledge' }" active-class="active-link"
          ><span class="navname">
            <BookOutlined />
            <span style="margin-left: 6px">知识管理</span>
          </span></router-link
        >
      </li>
      <li>
        <router-link to="/document" active-class="active-link"
          ><span class="navname">
            <FileMarkdownOutlined />
            <span style="margin-left: 6px">指标超市</span>
          </span></router-link
        >
      </li>
      <li>
        <router-link to="/feedback" active-class="active-link"
          ><span class="navname">
            <PieChartOutlined />
            <span style="margin-left: 6px">数据看板</span>
          </span></router-link
        >
      </li>
    </ul>
    <div class="spacer">
      <UserMenu class="usermenu" />
    </div>
  </nav>
</template>

<script setup>
import {
  UsergroupAddOutlined,
  DatabaseFilled,
  BookOutlined,
  FileMarkdownOutlined,
  PieChartOutlined,
  UserOutlined,
  LogoutOutlined,
  HomeOutlined,
} from "@ant-design/icons-vue";

// 假设这是从后端获取的用户信息
import avatar from "@/assets/images/pmys.gif"; // "https://example.com/path/to/avatar.jpg";
import { useStore } from "vuex";
import { computed, ref, onMounted } from "vue";
const store = useStore();
import router from "@/router/index";

import UserMenu from "../components/UserMenu.vue";
</script>

<style scoped>
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 60px;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 0px 20px;
  z-index: 1000;
}

.logo img {
  height: 40px;
  margin-left: 20%;
}

.navname {
  display: flex;
  justify-content: left;
  align-items: center;
}

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  margin-left: 10%;
  margin-top: 6px;
}

.nav-links li {
  margin: 0 50px;
}

.nav-links a {
  text-decoration: none;
  color: #6b6b6b;
  font-weight: bold;
  font-size: 17px;
  transition: color 0.3s ease;
  position: relative;
}

/*暂时去掉下划线
.nav-links a::after {
  content: "";
  position: absolute;
  width: 0;
  height: 3.1px;
  background-color: #007bff;
  right: 0px;
  bottom: -5px;
  transition: width 0.5s ease;
}

.nav-links a:hover::after,
.nav-links a.active-link::after {
  width: 80px;
}
  */

.nav-links a:hover,
.nav-links a.active-link {
  color: #007bff;
}

.spacer {
  margin-left: auto;
  margin-right: 5%;
}

.username {
  margin-left: 10px;
  line-height: 60px;
  font-size: 17px;
  color: #6b6b6b;
  font-weight: bold;
}

/* 下拉菜单样式 */
.navbar .ant-dropdown-trigger {
  cursor: pointer;
}

.navbar .ant-dropdown-menu {
  min-width: 100px;
}

/* 调整下拉菜单的位置 */
.navbar .ant-dropdown-menu {
  min-width: 100px;
  margin-top: 30px; /* 添加额外的顶部边距 */
}

.navbar .ant-dropdown-menu-item {
  padding: 8px 16px;
}

.navbar .ant-dropdown-menu-item:hover {
  background-color: #f5f5f5;
}

::v-deep .spacer .usermenu .username {
  color: rgb(41, 41, 41);
}
</style>
